#ifdef GL_ES
    precision mediump float;
#endif

varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;

uniform int selectZoneSize;
uniform float imgWidth;
uniform float imgHeight;

void main() {
	vec4 newColor;//=texture2D(u_texture, v_texCoords);
	
	float xOff,yOff,newX,newY;
	xOff=1.0/imgWidth;
	yOff=1.0/imgHeight;
	//xOff+=0.01;
	//yOff+=0.01;
	int p=0;
	for(int i=-selectZoneSize;i<=selectZoneSize;i++){
		newX=v_texCoords.x+xOff*i;
		
		/*
		newColor+=texture2D(u_texture,vec2(newX,v_texCoords.y));
		p++;
		*/
		for(int j=-selectZoneSize;j<=selectZoneSize;j++){
			newY=v_texCoords.y+yOff*j;
			//if(newX>=0 && newX<=1 && newY>=0 && newY<=1){
				newColor+=texture2D(u_texture,vec2(newX,newY));
				p++;
			//}
		}
		
	}
	/*
	for(int j=-selectZoneSize;j<=selectZoneSize;j++){
			newY=v_texCoords.y+yOff*j;
			newColor+=texture2D(u_texture,vec2(v_texCoords.x,newY));
			p++;
		}
	*/
	if(p>0){
		newColor/=p;
	}
	
    gl_FragColor = newColor*v_color;
}

